\subsection{Complex numbers}

When Eigenmath starts up, it defines symbol $i$ as $i=\sqrt{-1}$.
Symbol $i$ can be redefined and used for some other purpose if need be.

\bigskip
\noindent
Complex quantities can be entered in either rectangular or polar form.

{\color{blue}
\begin{verbatim}
a + i b
\end{verbatim}
}

\noindent
$a+ib$

{\color{blue}
\begin{verbatim}
exp(1/3 i pi)
\end{verbatim}
}

\noindent
$\exp\left(\tfrac{1}{3}i\pi\right)$

\bigskip
\noindent
Converting a complex number to rectangular or polar coordinates causes
simplification of mixed forms.

{\color{blue}
\begin{verbatim}
A = 1 + i
B = sqrt(2) exp(1/4 i pi)
A - B
\end{verbatim}
}

\noindent
$1+i-2^{1/2}\exp\left(\tfrac{1}{4}i\pi\right)$

{\color{blue}
\begin{verbatim}
rect(last)
\end{verbatim}
}

\noindent
$0$

\bigskip
\noindent
Rectangular complex quantities, when raised to a power, are multiplied out.

{\color{blue}
\begin{verbatim}
(a + i b)^2
\end{verbatim}
}

\noindent
$a^2-b^2+2iab$

\bigskip
\noindent
When $a$ and $b$ are numerical and the power is negative, the evaluation is done as follows.
\begin{equation*}
(a+ib)^{-n}
=\left(\frac{a-ib}{(a+ib)(a-ib)}\right)^n=
\left(\frac{a-ib}{a^2+b^2}\right)^n
\end{equation*}

\noindent
Here are a few examples.

{\color{blue}
\begin{verbatim}
1/(2 - i)
\end{verbatim}
}

\noindent
$\tfrac{2}{5}+\frac{1}{5}i$

{\color{blue}
\begin{verbatim}
(-1 + 3 i)/(2 - i)
\end{verbatim}
}

\noindent
$-1+i$

\bigskip
\noindent
The absolute value of a complex number returns its magnitude.

{\color{blue}
\begin{verbatim}
abs(3 + 4 i)
\end{verbatim}
}

\noindent
$5$

\bigskip
\noindent
Since symbols can have complex values, the absolute value
of a symbolic expression is not computed.

{\color{blue}
\begin{verbatim}
abs(a + b i)
\end{verbatim}
}

\noindent
$\operatorname{abs}(a+ib)$

\bigskip
\noindent
The $mag$ function can be used instead of $abs$.
It treats symbols like $a$ and $b$ as real.

{\color{blue}
\begin{verbatim}
mag(a + b i)
\end{verbatim}
}

\noindent
$\displaystyle (a^2+b^2)^{1/2}$

\bigskip
\noindent
The imaginary unit can be changed from $i$ to $j$
by defining $j=\sqrt{-1}$.

{\color{blue}
\begin{verbatim}
j = sqrt(-1)
sqrt(-4)
\end{verbatim}
}

\noindent
$\displaystyle 2j$
